Eggs
for a Pokémon egg]] This page describes how Pokémon eggs work, as well as how to give the player an egg and how to customise it. Why is an egg an egg? The only difference between a Pokémon and an egg is that an egg has a non-zero number of steps left to hatch. This number is kept in the Pokémon's variable called eggsteps. For actual Pokémon, this number is zero. The method egg? checks whether an entity is an egg; it returns TRUE if it is, and FALSE if it is a Pokémon. It is used as follows: $Trainer.party0.egg? This example looks at the first entity in the player's party, and checks whether it is an egg. Egg creation Since an egg is exactly the same as a Pokémon (except that one of its variables is non-zero), an egg is generated in exactly the same way as a Pokémon is (with just two differences: eggsteps is set to a non-zero value, and the egg's nickname is set to "Egg"). An egg's level is automatically set to the level given by the variable EGGINITIALLEVEL (in the script section Settings). The generation of an egg is done in the script section PSystem_PokemonUtilities, in def Kernel.pbGenerateEgg - this method also adds the egg to the end of the player's party, if possible. If the player's party is full, nothing happens. The Pokémon's stats (e.g. nature, gender, IVs, moveset) are determined when the egg is generated, not when it hatches. This is also the reason why an egg can be modified after it is obtained, as explained below. The above is only true if an egg is being generated out of nowhere (e.g. an NPC spontaneously giving it to the player). Things are a little different if the egg was created through breeding at the Day Care - a different method is used to generate the egg in this case. See Breeding for more details. Egg sprite and icon The egg sprites and icons go in the same folders as Pokémon sprites and icons ("Graphics/Battlers" and "Graphics/Icons" respectively). The default egg sprite and icon have the following names: * egg.png - The sprite. * iconEgg.png - The icon, two 64x64 pictures side-by-side just like all other Pokémon icons. Essentials allows for species-specific egg sprites and icons. To do this, name those sprite and icon files the following: * XXXegg.png - The sprite. * XXXeggCracks.png - The crack graphics overlaid onto the egg sprite when it hatches. * iconXXXegg.png - The icon. In all cases, "XXX" is the internal name of the species or its ID number padded to 3 digits. An example of a species with custom egg sprites that is already in Essentials is Manaphy. If a species does not have its own egg sprite/cracks/icon, it will use the default ones. Giving the player an egg To generate a Pokémon egg, use Kernel.pbGenerateEgg(:PIKACHU). This will add an egg to the end of the player's party (if there is space; it will do nothing if there isn't), which will hatch into the stated Pokémon. Kernel.pbGenerateEgg does not show any messages. It returns TRUE if the egg was added, or FALSE if there was no space in the player's party. You should use it like so: @>Conditional Branch: Script: Kernel.pbGenerateEgg(:TOGEPI) @>Text: Received a Pokémon Egg. : Else @>Text: You have no room to store the Egg... : Branch End This example creates and adds a Togepi egg. Note the colon before the internal name of the species. This method allows for a second argument, which is a phrase that overrides the name of the map which the egg was obtained on. This phrase is shown in the summary screen of the egg and the hatched Pokémon. Define this as follows: Kernel.pbGenerateEgg(:TOGEPI,_I("Mr. Pokémon")) Customising the egg Since the only difference between a Pokémon and an egg is a single variable (eggsteps), the Pokémon that will hatch from the egg can be modified in any way that a Pokémon can be modified. While you can predefine a Pokémon egg and then give it to the player via Kernel.pbGenerateEgg(pkmn) (where poke is the predefined egg), it is just as easy to give an egg to the player first and then customise it. This is because Kernel.pbGenerateEgg can only add an egg to the end of a player's party (i.e. it will not be sent to the PC if there is no room), so the newly obtained egg will always be in an easily accessible place for customising. Firstly, add the egg as mentioned above. Then, immediately after adding it (i.e. in the Conditional Branch next to the message stating the egg was given) add a script event command which says something like: egg = $Trainer.lastParty egg.makeShiny egg.makeFemale egg.pbLearnMove(:HYPERBEAM) egg.calcStats The first line finds the newly added egg (which will always be at the end of the player's party) and labels it "egg". It could just as easily label it "p" or "sausage" - this is just a way of easily referring to it, because "egg" is a shorter word than "$Trainer.lastParty". This line is necessary. The last line (egg.calcStats) is only necessary if something has been changed that will affect the Pokémon's stats (e.g. nature, form). However, there is no harm in including it anyway. The lines in the middle are the modifications made to the egg. In this example, the egg has been made shiny, female, and it will know Hyper Beam. See Editing a Pokémon for a list of possible modifications. Egg summary screen Eggs have a different summary screen to Pokémon. Firstly, there is just one page to it, and secondly, nearly all the information is missing and replaced with a message stating where/when the egg was obtained and how soon it will hatch. The contents of this summary screen can be found in the script section PScreen_Summary, in def drawPageOneEgg. Hatching an egg An egg requires a certain number of steps to be taken before it will hatch (this number depends on the species - see the StepsToHatch property of a species in the page Defining a species). Each step taken by the player reduces the egg's eggsteps variable by 1. When this variable reaches zero, the egg will hatch. The code that does all this is at the bottom of the script section PScreen_EggHatching. There is an animation which plays when an egg hatches, which shows the egg hatching. This animation is in the script section PScreen_EggHatching. After hatching, the player gets a chance to give the Pokémon a nickname. A newly hatched Pokémon will be at the level given by the variable EGGINITIALLEVEL (in the script section Settings). This variable can easily be changed to any other (valid) number. Some abilities change how quickly an egg hatches. Both Flame Body and Magma Armor double the rate at which eggsteps is reduced for all eggs in the party; these abilities do not stack with themselves or each other, though.